package com.zk.mall.servlet;

import com.zk.mall.entity.Admin;
import com.zk.mall.service.AdminService;
import com.zk.mall.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        AdminService adminService=new AdminServiceImpl();
        List<Admin> adminList=adminService.showAdmin();
        req.setAttribute("adminList",adminList);
        req.getRequestDispatcher("showAdmin.jsp").forward(req,resp);
    }
}
